<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/default.xhtml"
 	xmlns:sec="http://www.springframework.org/security/facelets/tags">  
	<ui:define name="content">
		<!-- Formulário de Agendamento -->
		<h:form id="frmSchedule" styleClass="form-horizontal" prependId="false">
			<p:outputPanel id="panelAgenda">
				<fieldset>
					<legend>#{messages.TITLE_AGENDAR_CHAMADO}</legend>
				</fieldset>
	
				<p:schedule id="schedule" widgetVar="agenda" value="#{agendaController.scheduleModel}" locale="agenda_pt"
					timeZone="America/Sao_Paulo" resizable="false" >
	
					<!-- eventos -->
	                <p:ajax event="dateSelect" listener="#{agendaController.novo}" update="eventosAgenda" oncomplete="modalAgenda.show()"/>
	                <p:ajax event="eventSelect" listener="#{agendaController.selecionado}" update="eventosAgenda" oncomplete="modalAgenda.show()" />  
					<p:ajax event="eventMove" listener="#{agendaController.movido}" oncomplete="agenda.update();"/>  
					<p:ajax event="eventResize" listener="#{agendaController.redimencionado}" oncomplete="agenda.update()"/>  
			    </p:schedule>
			</p:outputPanel>

			<!-- Dialog de confirmação ações -->
			<p:dialog widgetVar="modalAgenda" header="#{messages.TITLE_HEADER_AGENDAR}" resizable="false" modal="true" width="600">
				<p:outputPanel id="eventosAgenda">
	
					<div class="control-group">
						<h:outputLabel for="cmbResumoSearch" value="#{messages.LABEL_RESUMO}:" styleClass="control-label required"/>
						<div class="controls">
							<h:selectOneMenu id="cmbResumoSearch" value="#{agendaController.agenda.chamado}" label="#{messages.LABEL_RESUMO}" converter="entityConverter">
								<f:selectItem itemLabel="Selecione o #{messages.LABEL_RESUMO}"/>
								<f:selectItems value="#{agendaController.chamados}" var="chamado" itemLabel="#{chamado.resumo}"/>
							</h:selectOneMenu>
						</div>
					</div>
		
					<div class="control-group">
						<h:outputLabel for="txtDataAgendamento" value="#{messages.LABEL_DATA_INICIO}:" styleClass="control-label"/>
						<div class="controls">
							<p:inputText id="txtDataAgendamento" value="#{agendaController.agenda.dataInicio}"
								label="#{messages.LABEL_DATA}" styleClass="input-medium" disabled="true">
							
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</p:inputText>
						</div>
					</div>

					<div class="control-group">
						<h:outputLabel for="txtDataFim" value="#{messages.LABEL_DATA_FIM}:" styleClass="control-label required"/>
		                   <div class="controls">
							<p:calendar id="txtDataFim" value="#{agendaController.agenda.dataFim}" showOn="button"
								pattern="dd/MM/yyyy" locale="pt"/>
						</div>
					</div>

					<div class="control-group">
						<h:outputLabel for="txtHoraAgendamento" value="#{messages.LABEL_HORARIO}:" styleClass="control-label required"/>
		                <div class="controls">
							<p:inputText id="txtHoraAgendamento" value="#{agendaController.agenda.horarioAgendamento}"
								label="#{messages.LABEL_DATA}" styleClass="input-medium">
								<f:convertDateTime pattern="HH:mm" />
							</p:inputText>
						</div>
					</div>
		
					<div class="control-group">
						<h:outputLabel for="txtEndereco" value="#{messages.LABEL_ENDERECO}:" styleClass="control-label required"/>
		                <div class="controls">
							<p:inputText id="txtEndereco" value="#{agendaController.agenda.endereco}" maxlength="50"
								label="#{messages.LABEL_ENDERECO}" styleClass="input-large"/>
						</div>
					</div>
	
					<div class="form-actions">
						<p:commandButton id="btnSalvar" value="#{messages.BTN_SALVAR}" action="#{agendaController.salvar()}" 
		                 styleClass="btn" update="schedule" oncomplete="agenda.update();"/>
		                	
		                <p:commandButton id="btnExcluir" value="#{messages.LABEL_EXCLUIR}" action="#{agendaController.excluir()}" rendered="#{agendaController.isExcluir}"
		                	styleClass="btn" update="schedule" oncomplete="agenda.update();modalAgenda.hide();"/>
		                	
		                <p:commandButton value="#{messages.LABEL_CANCELAR}" styleClass="btn" type="button" onclick="modalAgenda.hide();"/>
					</div>
				</p:outputPanel>
			</p:dialog>
		</h:form>
	   	<!-- End Dialog de confirmação de ações -->
	</ui:define>
</ui:composition>